package com.quark.framework.utility;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.StringReader;
import java.util.ArrayList;

public class QuarkUtilFileReader {

	public static String readAllString(String name)
	{
		String[] lines = readLines(name);
		String ret = "";
		if (lines != null)
		{
			for(int i = 0; i < lines.length; i++)
			{
				ret += lines[i];
			}			
		}
		return ret;
	}
	
	public static String[] readLines(String name)
	{
		File file = new File(name);
		ArrayList<String> list = new ArrayList<String>();
		String[] lines = null;
		if(!file.exists())
			return null;
		try
		{
			BufferedReader reader = new BufferedReader(new FileReader(file));
			String line = "";
			
			while((line = reader.readLine()) != null)
			{
				list.add(line);
			}
		}catch(Exception e)
		{
			QuarkLog.log(e);
		}
		lines = new String[list.size()];
		list.toArray(lines);
		return lines;
	}
}
